import { useState, useEffect } from "react"

// 手动触发
export function useApiHookManual(fn, params) {
    const [data, setData] = useState(null)
    const [error, setError] = useState(null)
    const [loading, setLoading] = useState(true)

    const fetchData = async () => {
        try {
            const result = await fn(params)
            setData(result)
        } catch (err) {
            setError(err)
        } finally {
            setLoading(false)
        }
    }

    return { data, error, loading, fetchData }
}
